]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
browser-plugin: Make sure to use the UTF8Length parameter
authorJasper St. Pierre <jstpierre@mecheye.net>
Thu, 17 Nov 2011 04:47:35 +0000 (23:47 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Sun, 4 Dec 2011 15:31:04 +0000 (10:31 -0500)
Some plugin hosts may have junk after the UTF8Characters that we need to strip
off. No current browsers that I know of do this, but it still helps to be
correct.

browser-plugin/browser-plugin.c

index 385550c3460416b9b7ff1f6e1fa96842023038ea..e9f99502b76735ff1634c0c12d20222bab9a9b3e 100644 (file)
@@ -455,7 +455,7 @@ plugin_enable_extension (PluginObject *obj,
                          NPString      uuid,
                          gboolean      enabled)
 {
-  const gchar *uuid_str = uuid.UTF8Characters;
+  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -468,6 +468,8 @@ plugin_enable_extension (PluginObject *obj,
                      NULL, /* callback */
                      NULL /* user_data */);
 
+  g_free (uuid_str);
+
   return TRUE;
 }
 
@@ -476,7 +478,7 @@ plugin_install_extension (PluginObject *obj,
                           NPString      uuid,
                           NPString      version_tag)
 {
-  const gchar *uuid_str = uuid.UTF8Characters;
+  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -491,6 +493,8 @@ plugin_install_extension (PluginObject *obj,
                      NULL, /* callback */
                      NULL /* user_data */);
 
+  g_free (uuid_str);
+
   return TRUE;
 }
 
@@ -501,9 +505,9 @@ plugin_uninstall_extension (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -516,6 +520,8 @@ plugin_uninstall_extension (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to uninstall extension: %s", error->message);
@@ -533,9 +539,9 @@ plugin_get_info (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -547,6 +553,8 @@ plugin_get_info (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to retrieve extension metadata: %s", error->message);
@@ -564,9 +572,9 @@ plugin_get_errors (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -578,6 +586,8 @@ plugin_get_errors (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to retrieve errors: %s", error->message);